﻿using System;
using System.Data;
using System.Collections.Generic;
using Chenxin.Lib.House.Entity;

namespace Chenxin.Lib.House.BLL
{
    /// <summary>
    /// 业务逻辑类DataDictionary 的摘要说明。
    /// </summary>
    public class DataDictionaryItem
    {
        public DataDictionaryItem()
        { }


        #region  成员方法
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Chenxin.Lib.House.Entity.DataDictionaryItem GetModel(string ItemKey)
        {

            return Chenxin.Lib.House.DAL.DataDictionaryItem.GetModel(ItemKey);
        }

        /// <summary>
        /// 获得数据列表
        /// </summary>
        public DataSet GetList(string strWhere, string strOrder)
        {
            return Chenxin.Lib.House.DAL.DataDictionaryItem.GetList(strWhere, strOrder);
        }
        ///// <summary>
        ///// 获得前几行数据
        ///// </summary>
        //public DataSet GetList(int Top, string strWhere, string filedOrder)
        //{
        //    return Chenxin.Lib.House.DAL.DataDictionary.GetList(Top, strWhere, filedOrder);
        //}
        /// <summary>
        /// 获得数据列表
        /// </summary>
        public List<Chenxin.Lib.House.Entity.DataDictionaryItem> GetModelList(string strWhere, string strOrder)
        {
            DataSet ds = Chenxin.Lib.House.DAL.DataDictionaryItem.GetList(strWhere, strOrder);
            return DataTableToList(ds.Tables[0]);
        }

        public List<Chenxin.Lib.House.Entity.DataDictionaryItem> GetDicList(string strKey)
        {
            string strWhere;
            string strOrder;

            strWhere = " ItemKey = '" + strKey + "'";
            strOrder = " ItemKey";
            return GetModelList(strWhere, strOrder);
        }


        /// <summary>
        /// 获得数据列表
        /// </summary>
        public List<Chenxin.Lib.House.Entity.DataDictionaryItem> DataTableToList(DataTable dt)
        {
            List<Chenxin.Lib.House.Entity.DataDictionaryItem> modelList = new List<Chenxin.Lib.House.Entity.DataDictionaryItem>();
            int rowsCount = dt.Rows.Count;
            if (rowsCount > 0)
            {
                Chenxin.Lib.House.Entity.DataDictionaryItem model;
                for (int n = 0; n < rowsCount; n++)
                {
                    model = new Chenxin.Lib.House.Entity.DataDictionaryItem();
                    model.ItemKey = dt.Rows[n]["ItemKey"].ToString();
                    model.ItemRemark = dt.Rows[n]["ItemRemark"].ToString();
                    modelList.Add(model);
                }
            }
            return modelList;
        }

        /// <summary>
        /// 获得数据列表
        /// </summary>
        public DataSet GetAllList()
        {
            return GetList("", "");
        }

        /// <summary>
        /// 获得数据列表
        /// </summary>
        //public DataSet GetList(int PageSize,int PageIndex,string strWhere)
        //{
        //return dal.GetList(PageSize,PageIndex,strWhere);
        //}

        #endregion  成员方法
    }
}
